<?php
session_start();
if (isset($_SESSION["username"])) {
?>
    <?php require_once('common/header.php'); ?>
    <!--页面主要内容-->
    <main class="lyear-layout-content">
        <div class="container-fluid">
            <div class="card">
                <div class="card-header bg-primary">
                    <h4>加入渠道</h4>
                </div>
                <div class="card-body">
                   <form class="form-horizontal" action="controller/uplistchannel.php" method="POST">
                        <div class="form-group">
                            <label class="col-xs-12">加入渠道：</label>
                            <div class="col-xs-12">
                           <select name="channel_name" id="channel_name" class="form-control">
                              <option value="">请选择渠道</option>
                              <?php
                                 include_once("../untils/conn.php");
                                 mysqli_query($con, "set names utf8");
                                 $id = $_GET['id'];
                                 // 获取所有渠道
                                 $channel_sql = "SELECT `channel_name` FROM `channel`";
                                 $channel_data = mysqli_query($con, $channel_sql);
                              
                                 // 将查询结果转换为关联数组
                                 $channel_array = mysqli_fetch_all($channel_data, MYSQLI_ASSOC);
                              
                                 foreach($channel_array as $channel) {
                                    echo "<option value='{$channel['channel_name']}'>{$channel['channel_name']}</option>";
                                 }
                              ?>
                           </select>
                        </div>

                        </div>
                    
                        <div class="form-group">
                            <input type="hidden" name="id" value="<?php echo $id ?>">
                            <div class="offset-2 col-xs-12">
                                <button class="btn btn-success" type="submit" value="添加">确认修改</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
        </div>
        </div>
        </div>
        </div>


        </div>
    </main>
    <!--End 页面主要内容-->
    <?php require_once('common/footer.php'); ?>
<?php
} else {
    echo "<script>alert('您尚未登录，没有权限访问该页面');location.href='login.php';</script>";
}
